#include "Def.h"
#include <qcompleter.h>
#include "ScriptLineEdit.h"
#include "ScriptExecutor.h"
#include "SDKCore.h"

ScriptLineEdit::ScriptLineEdit(QWidget* parent) :
QLineEdit(parent)
{
	connect(this,SIGNAL(returnPressed()),this,SLOT(search()));
}

ScriptLineEdit::~ScriptLineEdit()
{
}

void ScriptLineEdit::init(const QStringList& input)
{
	auto comp = new QCompleter(input,this);
	comp->setFilterMode(Qt::MatchContains);
	setCompleter(comp);
}

void ScriptLineEdit::search()
{
	SDKCore::instance()->getScriptExecutor()->execute(text());
}